package com.njym.java.security.app.rest;


import com.github.pagehelper.PageInfo;
import com.njym.java.security.app.biz.LectureBiz;
import com.njym.java.security.app.entity.Lecture;
import com.njym.java.security.app.entity.Lecturer;
import com.njym.java.security.common.rest.BaseController;
import com.njym.java.security.common.util.ResponseUtil;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import tk.mybatis.mapper.entity.Example;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("lecture")
public class LectureController extends BaseController<LectureBiz,Lecture> {
    @RequestMapping(value = "/getList", method = RequestMethod.GET)
    @ResponseBody
    public Object getList(String teacherId){
        Integer id = 0;
        if(!"undefined".equals(teacherId)){
            id = Integer.parseInt(teacherId);
        }
        Example example = new Example(Lecture.class);
        example.createCriteria().andEqualTo("jsId", id);
        example.setOrderByClause("start_time DESC");
        List<Lecture> list = baseBiz.selectByExample(example);

        Map<String, Object> data = new HashMap<>(1);
        data.put("list", list);
        return ResponseUtil.ok(data);
    }
}